package com.iory.tianwangterminator;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

public class ProvinceActivity extends ListActivity {

private static final String[] CITY_DATA = {"成都", "绵阳","广汉"};
	
	
	private ArrayList<HashMap<String,Object>>  mCityData;
	SimpleAdapter mListAdapter;
	ListView mListView;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		//requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.province);
		mListView = getListView();
		initListAdapter();
		

	}

	private void initListAdapter() {
		//getDraftData();
		mCityData = new ArrayList<HashMap<String, Object>>();
		for(int i=0;i<3;i++)   
		{
			HashMap<String, Object> map = new HashMap<String, Object>(); 
			map.put("icon", R.drawable.camera); 
	        map.put("name", CITY_DATA[i]);
	        map.put("arrow", R.drawable.arrow);   
	        mCityData.add(map);
		}
		mListAdapter = new SimpleAdapter(this,mCityData,  
	            R.layout.main_listitem,      
	            new String[] {"icon","name", "arrow"},     
	            new int[] {R.id.ItemImage,R.id.ItemTitle,R.id.item_arrow}   
	        );   
	                
	 mListView.setAdapter(mListAdapter);   

	 mListView.setOnItemClickListener(new OnItemClickListener() {   
	  @Override  
      public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {   
			Intent intent = new Intent (ProvinceActivity.this, CityActivity.class);
			Bundle bund = new Bundle();
			bund.putString("TypeName", mCityData.get(arg2).get("name").toString());
			intent.putExtras(bund);
			startActivity(intent);
        }   
    });
	}
	
}
